home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
PROGRAM
/
SNIP9_91.ARJ
/
PRTOGGLE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-12
|
880b
|
32 lines
/*
** prtoggle()
**
** Tee's all standard output to the printer.
**
** Parameters: None
**
** Returns: 0 if operation was successful.
** -1 if stdout or stdin is redirected.
**
** Side effects: Flushes the keyboard buffer
*/
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <io.h>
#ifdef __ZTC__ /* Zortech C/C++ doesn't support ungetch() */
#include <mflsys.h> /* Part of the MFLZT shareware library */
#endif
int cdecl prtoggle(void)
{
if (!isatty(fileno(stdin)) || !isatty(fileno(stdout)))
return -1;
while (kbhit()) /* Flush the keyboard buffer */
getch();
ungetch('P' - 64); /* Stuff a Ctrl-P into the buffer */
system(""); /* Let COMMAND.COM do the work */
return 0;
}